package com.gjh.study.mybatis.config;

import org.apache.ibatis.reflection.factory.DefaultObjectFactory;
import org.apache.log4j.Logger;

import java.util.List;
import java.util.Properties;

/**
 * @author guangjh
 * @version 1.0
 * @date 2020/7/10 21:58
 */
public class MyObjectFactory extends DefaultObjectFactory {

    private static final long serialVersionUID = 1L;

    Logger logger = Logger.getLogger(MyObjectFactory.class);

    public void setProperties(Properties properties) {
        super.setProperties(properties);
        logger.info("MyObjectFactory -> setProperties: " + properties);
    }

    @Override
    public <T> T create(Class<T> type) {
        T res = super.create(type);
        logger.info("MyObjectFactory -> create1: " + res.toString());
        return res;
    }

    @Override
    public <T> T create(Class<T> type, List<Class<?>> constructorArgTypes, List<Object> constructorArgs) {
        T res = super.create(type, constructorArgTypes, constructorArgs);
        logger.info("MyObjectFactory -> create2: " + res.toString());
        return res;
    }

    @Override
    public <T> boolean isCollection(Class<T> type) {
        boolean res = super.isCollection(type);
        logger.info("MyObjectFactory -> isCollection: " + res);
        return res;
    }
}
